from flask import Flask, request, jsonify
import requests

app = Flask(__name__)

# DeepSeek API 的地址
DEEPSEEK_API_URL = '待填'

# 你的 DeepSeek API Key
API_KEY = '待填'

@app.route('/', methods=['POST'])
def deepseek_proxy():
    try:
        # 获取小程序传递的请求数据
        data = request.json

        # 调用 DeepSeek API
        response = requests.post(
            DEEPSEEK_API_URL,
            json=data,
            headers={
                'Content-Type': 'application/json',
                'Authorization': f'Bearer {API_KEY}',
            },
        )

        # 将 DeepSeek API 的响应返回给小程序
        return jsonify(response.json()), response.status_code

    except Exception as e:
        # 如果发生错误，返回错误信息
        return jsonify({'error': str(e)}), 500

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)